<?php
/**
 * 用户接口模块
 * User: 10749
 * Date: 2017/6/5
 * Time: 18:41
 */
class Api_User extends PhalApi_Api{

    /**
     * 定义user模块的接口信息，包括接口名，参数
     * @return array
     */
    public function getRules()
    {
        return array(
            'userReg' => array(
                //配置请求参数
                "username" =>array('name' => 'username', 'type' => 'string', 'min' => 5,'max' => 25, 'require' => true, 'desc' => '用户名'),
                "nikename" =>array('name' => 'nikename', 'type' => 'string', 'min' => 5,'max' => 25, 'require' => true, 'desc' => '用户昵称'),
                "password" =>array('name' => 'password', 'type' => 'string', 'min' => 8,'max' => 32, 'require' => true, 'desc' => '用户密码'),
                "icon" =>array('name' => 'icon', 'type' => 'string',  'require' => false, 'desc' => '用户头像图片地址'),
                "age" =>array('name' => 'age', 'type' => 'int', 'min' => 8,'max' => 100, 'require' => false, 'desc' => '用户年龄'),
                "phone" =>array('name' => 'phone', 'type' => 'string', 'min' => 11,'max' => 11, 'require' => false, 'desc' => '用户电话号码'),
                "desc" =>array('name' => 'desc', 'type' => 'string', 'min' => 1,'max' => 80, 'require' => false, 'desc' => '用户自我说明'),
                "sex" =>array('name' => 'sex', 'type' => 'string', 'min' => 1,'max' => 1, 'require' => false, 'desc' => '用户性别'),
            ),
            'userLogin' => array(
                "username" =>array('name' => 'username', 'type' => 'string', 'min' => 5,'max' => 25, 'require' => true, 'desc' => '用户名'),
                "password" =>array('name' => 'password', 'type' => 'string', 'min' => 8,'max' => 32, 'require' => true, 'desc' => '用户密码'),
            ),
            'getUserList' => array(),
            'getUserById' => array(
                "userid" =>array('name' => 'userid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户id'),
            ),
        );
    }

    //定义相应的方法承载接口

    /**
     * 用户注册
     */
    public function userReg(){
        $Domain_User = new Domain_User();
        return $Domain_User->userReg($this);
//        return "接口：用户注册";
    }

    /**
     * 用户登录
     */
    public function userLogin(){
        return "接口：用户登录";
    }

    /**
     * 获取用户列表
     */
    public function getUserList(){
        return "接口：获取用户列表";
    }

    /**
     * 获取用户详情
     */
    public function getUserById(){
        $Domain_User = new Domain_User();
        return $Domain_User->getUserById($this->userid);
        return "接口：获取用户详情";
    }

}
